
import java.util.logging.Level;
import java.util.logging.Logger;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author hoang long
 */
public class ThreadTest
{


    public static void main(String[] a){
        Thread1 t1 = new Thread1();
        t1.start();

        Runnable1 r1= new Runnable1();
        Thread t2 = new Thread(r1);
        t2.start();



    }

}

class Thread1 extends Thread
{

    @Override
    public void run() {
        //super.run();
        //int i;
        for (int i=1 ; i<=5;i++)
        {
           // System.out.println("*");
            
            //print " "
            for (int j = 1; j<= 5-i ; j++){
                System.out.print(" ");
            }

            //print *
            for (int j =1; j <= 2*i-1 ;j++){
                System.out.print("*");
            }

            System.out.print("\n");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
                Logger.getLogger(Thread1.class.getName()).log(Level.SEVERE, null, ex);
            }



        }

    }



}

class Runnable1 implements Runnable
{

    public void run()
    {
        for (int i=1;i<=5;i++){
            try {
                System.out.println(i * i);
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
                Logger.getLogger(Runnable1.class.getName()).log(Level.SEVERE, null, ex);
            }
        }

        //throw new UnsupportedOperationException("Not supported yet.");
    }
}
